package com.class2.java;

import com.alibaba.fastjson.JSONObject;
import com.class2.java.address.Address;
import com.class2.java.bean.HotVideo;
import com.class2.java.bean.HotVideoCommon;
import com.class2.java.com.class2.java.net.HttpUtils;
import com.class2.java.service.GetBestBlockHashService;
import com.class2.java.service.HotVideoService;

import java.security.KeyPair;
import java.util.List;
import java.util.Scanner;

/**
 * @author:yc
 * @email:1247616535@qq.com
 * @desc:
 * @datetime: 2021/12/21 12:47
 */

public class Main {
    public static void main(String[] args){

        int num = -1;
        while (true) {
            menu();
            int choice = -1;
            System.out.println("                                                       welcome to Yc' com.class2.java");
            System.out.println("                                                                   选择要进行的项目");
            //获取输入
            Scanner scanner = new Scanner(System.in);
            if (num == -1) {
                choice = scanner.nextInt();
            } else {
                choice = num;
            }

            if (choice == 6) {
                break;
            }
            switch (choice) {

                case 1:
                    //获取热门旅游城市数据
                    HotVideoService HotVideoService = new HotVideoService();
                    List<HotVideo> HotVideo = HotVideoService.getHotVideo();
                    System.out.println("成功获取到以下视频数据：" + HotVideo);
                    break;

                case 2:
                    //选择生成或者校验
                    System.out.println("选择项目类型：生成地址---输入1；校验地址---输入2");
                    String init = scanner.next();
                    if (init.equals("1")) {

                        Address Addr = new Address();
                        KeyPair KeyPair = Addr.generatekey();
                        String AddrStr = Addr.newAdderss(KeyPair);
                        System.out.println("成功获取到以下地址：" + AddrStr);
                    } else if (init.equals("2")) {
                        Address Addr = new Address();
                        KeyPair KeyPair = Addr.generatekey();
                        String AddrStr = Addr.newAdderss(KeyPair);
                        boolean result = Addr.isValidate(AddrStr);
                        System.out.println("验证成功：" + result);
                    }
                    break;

                case 3:
                    //获取哈希值
                    GetBestBlockHashService getBestBlockHashService = new GetBestBlockHashService();
                    Object bestBlockHashService  = getBestBlockHashService.getBestBlockHash();
                    System.out.println("获取到的哈希值是：" + bestBlockHashService);
                    break;

                case 4:
                    //退出项目
                    System.exit(4);

                    break;
                default:
                    System.out.println("                                                       输入错误重新输1、2、3、4");

                     ;
            }
        }
    }

    public static void menu() {
        System.out.println("                                                                       ");
        System.out.println("                                                       下面是YC的考察项目的功能                        ");
        System.out.println("                                                       请求热门旅游视频           输入：1 ");
        System.out.println("                                                       请求地址                  输入：2 ");
        System.out.println("                                                       请求哈希值                输入：3 ");
        System.out.println("                                                       退出                     输入：4 ");

    }

}

